<template>
    <wsPage :title="topicCategory.name+'-主题列表'">
        <div slot="page_operate">
			<Button @click="goback"><span>返回</span></Button>
		</div>
        <wsSmPanel>
            <!-- 数据列表 -->
            <!-- <div slot="list_operate">
                <Select class="ws-form-select" v-model="topicCategory.languageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
            </div> -->
            <!-- content -->
            <div slot="list_data" >
                <ws-table :data="table.data" >
                    <ws-table-column  label="名称" min-width="180" align="center">
                        <template slot-scope="scope">
                            <div style="display:flex;height:100px;">
                                <img :src="scope.row.coverImgUrl" alt="" style="width:100px;height:100px;">
                                <span style="line-height:100px;margin-left:10px;">{{scope.row.name}}</span>
                            </div>                           
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="标题" min-width="180" align="center">
                        <template slot-scope="scope">
                           <span>{{scope.row.title}}</span>
                        </template>   
                    </ws-table-column> 
                    <ws-table-column  label="语言" min-width="180" align="center">
                        <template slot-scope="scope">
                           <span>{{scope.row.languageCode}}</span>
                        </template>   
                    </ws-table-column>   
                    <ws-table-column  label="创建时间" min-width="180" align="center">
                        <template slot-scope="scope">
                           <span>{{scope.row.createDate}}</span>
                        </template>   
                    </ws-table-column>  
                    <ws-table-column  label="更新时间" min-width="180" align="center">
                        <template slot-scope="scope">
                           <span>{{scope.row.updateDate}}</span>
                        </template>   
                    </ws-table-column>
                </ws-table>
            </div>
        </wsSmPanel>
    </wsPage>
</template>

<script>
import Util from '../../../common/util.js';
import FileUtil from '../../../common/file.js';
import Common from '../../../common/common.js';
import $ from "jquery";
export default {
    data(){
        return {
            table: {
                data: [],
                page: {
                    total: 0, //总条数
                    pageNum: 1, //当前页
                    pageSize: 10 //每页显示条数
                },
                selection: [] //选中
            },
            // 语言类型
            fields: {
                languages: []
            },
            topicCategory:{
                languageCode:'zh',
                list:[], //存放主题分类列表
                id:'',
                name:''
            },
        }
    },
    computed:{

    },
    mounted(){
        // 对应主题分类id
        this.topicCategory.id=this.$route.query.id;
        this.topicCategory.name=this.$route.query.name;
        this.init();
    },
    methods:{
          init(){
            this.initLanguages();
            this.getTopicList();
        },
         /**
         * 加载翻译语言列表
         */
        initLanguages() {
            const _this = this;
            this.axios.get('/ws/ops/v2/languages/translatable').then(response => {
                var res = response.data;
                var resMeta = res.meta;
                if(0 == resMeta.code) {
                    _this.fields.languages = res.data;
                } else {
                    _this.$Message.warning(resMeta.message);
                }
            });
        },
        // 获得对于主题分类下的主题列表
        getTopicList(){
            let _this=this;
            this.axios.put('/ws/ops/v2/topic/'+_this.topicCategory.id).then(response=>{
                var res = response.data;
                console.log(res);
                var resMeta = res.meta;
                if(0 == resMeta.code) {
                    _this.table.data = res.data;
                } else {
                    _this.$Message.warning(resMeta.message);
                }
            })
            
        },
        // 返回
        goback(){
            this.$router.push('/topicCategory/list');
        }
    }
}
</script>

<style>

</style>
